package com.sicheng.lc.周赛.分类.模拟;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/16 16:03
 */
public class 统计是给定字符串前缀的字符串数目 {
    //https://leetcode.cn/problems/count-prefixes-of-a-given-string/
    public int countPrefixes(String[] words, String s) {
        int count = 0;
        for (String word : words) {
            if (word.length() <= s.length()) {
                int i = 0;
                for (; i < word.length(); i++) {
                    if (word.charAt(i) != s.charAt(i)) {
                        break;
                    }
                }
                count += i == word.length() ? 1 : 0;
            }
        }
        return count;
    }

    public static void main(String[] args) {

    }
}
